/*
 * 项目名称:platform-plus
 * 类名称:StaffMapServiceImpl.java
 * 包名称:com.platform.modules.staff.service.impl
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2020-11-24 14:58:04        klwu     初版做成
 *
 * Copyright (c) 2019-2019 klwu
 */
package com.platform.modules.custmoer.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.common.utils.Query;
import com.platform.modules.custmoer.dao.StaffMapDao;
import com.platform.modules.custmoer.entity.StaffMapEntity;
import com.platform.modules.custmoer.service.StaffMapService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *
 * @author klwu
 * @date 2020-11-24 14:58:04
 */
@Service("staffMapService")
public class StaffMapServiceImpl extends ServiceImpl<StaffMapDao, StaffMapEntity> implements StaffMapService {

    @Override
    public List<StaffMapEntity> queryAll(Map<String, Object> params) {
        return baseMapper.queryAll(params);
    }

    @Override
    public Page queryPage(Map<String, Object> params) {
        //排序
//        params.put("sidx", "T.CREATE_TIME");
//        params.put("asc", false);
        System.out.print(!params.get("date1").equals(""));
        if(params.get("date1") != null && !"".equals(params.get("date1"))){
            String searchDate = params.get("date1").toString();
            params.put("date1",searchDate+" 00:00:00");
            params.put("date2",searchDate+" 23:59:59");
        }

        Page<StaffMapEntity> page = new Query<StaffMapEntity>(params).getPage();
        return page.setRecords(baseMapper.selectStaffMapPage(page, params));
    }

    @Override
    public boolean add(StaffMapEntity staffMap) {
        return this.save(staffMap);
    }

    @Override
    public boolean update(StaffMapEntity staffMap) {
        return this.updateById(staffMap);
    }

    @Override
    public boolean delete(String id) {
        return this.removeById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteBatch(String[] ids) {
        return this.removeByIds(Arrays.asList(ids));
    }
}
